package cn.zsb.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.hibernate.validator.constraints.URL;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Future;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

@ApiModel("广告")
public class Advtise implements Serializable {
    @ApiModelProperty("编号")
    private long id;

    @ApiModelProperty("广告标题")
    @NotBlank(message = "标题不能为空")
    @Length(max = 30,message = "标题太长")
    private String title;
    @NotBlank(message = "跳转网址不能为空")
    @Length(min = 4,max = 100,message = "长度必须在4-100之间")
    @URL(message = "必须符合一个url格式")
    @ApiModelProperty("广告网址")
    private String url;

    @ApiModelProperty("广告是否还有效")
    private boolean isvalid;
    @Range(min = 1,message = "排序不能小于1")

    @ApiModelProperty("轮播广告的顺序")
    private int sortorder;

    @ApiModelProperty("广告发布时间")
    @Future(message = "时间必须是将来的时间")
    //@DateTimeFormat(pattern = "yyyy-MM-dd hh:mm")
    @JsonFormat(pattern = "yyyy-MM-dd hh:mm")
    private Date starttime;

    @ApiModelProperty("图片")
    @NotBlank(message = "图片必须要")
    @Length(max =240 ,message = "图片路径不能太长")
    private String imgurl;

    @ApiModelProperty("广告打开的地方")
    private String target;

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public boolean isIsvalid() {
        return isvalid;
    }

    public void setIsvalid(boolean isvalid) {
        this.isvalid = isvalid;
    }

    public int getSortorder() {
        return sortorder;
    }

    public void setSortorder(int sortorder) {
        this.sortorder = sortorder;
    }

    public Date getStarttime() {
        return starttime;
    }

    public void setStarttime(Date starttime) {
        this.starttime = starttime;
    }

    public String getImgurl() {
        return imgurl;
    }

    public void setImgurl(String imgurl) {
        this.imgurl = imgurl;
    }

    public String getTarget() {
        return target;
    }

    public void setTarget(String target) {
        this.target = target;
    }

    @Override
    public String toString() {
        return "Advtise{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", url='" + url + '\'' +
                ", isvalid=" + isvalid +
                ", sortorder=" + sortorder +
                ", starttime=" + starttime +
                ", imgurl='" + imgurl + '\'' +
                ", target='" + target + '\'' +
                '}';
    }
}
